#include <chrono>
#include <memory>
#include <rclcpp/rclcpp.hpp>
#include <rosgraph_msgs/msg/clock.hpp>

using namespace std::chrono_literals;

namespace simulator{

class ClockNode : public rclcpp::Node
{
public:
ClockNode()
: rclcpp::Node("clock_node")
{

  clock_pub_ = this->create_publisher<rosgraph_msgs::msg::Clock>("/clock", 10);
  timer_ = this->create_wall_timer(
    std::chrono::milliseconds(5), std::bind(&ClockNode::publish_clock, this));
}

private:

void publish_clock()
{
  auto clock_msg = rosgraph_msgs::msg::Clock();
        clock_msg.clock = this->get_clock()->now();
        clock_pub_->publish(clock_msg);
  
}
rclcpp::TimerBase::SharedPtr timer_;
rclcpp::Publisher<rosgraph_msgs::msg::Clock>::SharedPtr clock_pub_;
};
}
int main(int argc, char * argv[])
{
  rclcpp::init(argc, argv);
  rclcpp::spin(std::make_shared<simulator::ClockNode>());
  rclcpp::shutdown();
  return 0;
}
